package com.jindu.producer.finance.jpa;

import com.jindu.producer.finance.model.FExperEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * @author jarvischang
 * @date 2018-10-19
 */
@Transactional
public interface ExperJpa  extends JpaRepository<FExperEntity,Long> ,JpaSpecificationExecutor {

    /**
     * 根据id 查询 单个实体
     * @param id
     * @return
     */
    FExperEntity findById(String id);

    /**
     * 根据产品的id 查询数据
     * @param productId
     * @return
     */
    List<FExperEntity> findByProductId(String productId);


    List<FExperEntity> findByUserIdAndProductId(String userId,String productId);


    /**
     * 根据id删除数据
     * @param id
     * @return
     */
    @Modifying
    @Query("delete from FExperEntity where id = ?1 ")
    int deleteById(String id);

}
